Skip to content

feat: support sqllogictest output coloring#20368

Merged
Jefffrey merged 3 commits intoapache:mainfrom
theirix:sqllogictest-color
Feb 19, 2026
Merged

feat: support sqllogictest output coloring#20368
Jefffrey merged 3 commits intoapache:mainfrom
theirix:sqllogictest-color

Conversation

@theirix
Copy link
Contributor

@theirix theirix commented Feb 15, 2026

Which issue does this PR close?

Rationale for this change

It's more ergonomic to have colored diffs in sqllogictest's output.

The upstream library already supports it, and we can enable it based on the user's choice. This PR checks NO_COLOR, terminal settings, CARGO_TERM_COLOR and --color CLI argument. By default, the diff is colored.

Screenshot 2026-02-15 at 11 44 05

What changes are included in this PR?

  • sqllogictest driver output colouring with argument/flags analysis

Are these changes tested?

  • Tested different flag combinations

Are there any user-facing changes?

Respects NO_COLOR, terminal settings, CARGO_TERM_COLOR and `--color` CLI argument

Signed-off-by: theirix <theirix@gmail.com>
Signed-off-by: theirix <theirix@gmail.com>
@github-actions github-actions bot added the sqllogictest SQL Logic Tests (.slt) label Feb 15, 2026
@theirix theirix marked this pull request as ready for review February 15, 2026 12:45

#[clap(
long,
value_name = "WHEN",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
value_name = "WHEN",
value_name = "MODE",

@@ -813,6 +832,29 @@ impl Options {
eprintln!("WARNING: Ignoring `--show-output` compatibility option");
}
}

/// Determine if colour output should be enabled, respecting --color, NO_COLOR, CARGO_TERM_COLOR, and terminal detection
fn is_colored(&self) -> bool {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not as familiar with clap, but I feel some of this logic can be encoded using clap macros on Options? For example instead of it being a string it could be an enum (and thus in help we wouldn't need to mention the valid values ourselves?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely. I utilised the pre-made clap::ColorChoice enum to auto-populate the help and removed the option. It also required parsing CARGO_TERM_COLOR. Looks more concise now.
Example:

      --color <MODE>                 Control colored output [default: auto] [possible values: auto, always, never]

@Jefffrey Jefffrey added this pull request to the merge queue Feb 19, 2026
Merged via the queue into apache:main with commit 08c09db Feb 19, 2026
28 checks passed
@Jefffrey
Copy link
Contributor

Nice improvement, thanks @theirix, @xudong963 & @getChan

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

sqllogictest SQL Logic Tests (.slt)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support sqllogictest output coloring

4 participants

Comments